package com.campus.mapper;

import com.campus.annotation.AutoFill;
import com.campus.enumeration.OperationType;
import com.campus.pojo.dto.BusPageQueryDTO;
import com.campus.pojo.entity.Bus;
import com.campus.pojo.vo.BusVO;
import com.campus.result.PageResult;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BusMapper {
    Page<BusVO> pageQuery(BusPageQueryDTO busPageQueryDTO);

    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into bus (bus_number, route_info, first_time, last_time, interval_minutes, driver_name, driver_phone, capacity, status, create_time, update_time) values (#{busNumber}, #{routeInfo}, #{firstTime}, #{lastTime}, #{intervalMinutes}, #{driverName}, #{driverPhone}, #{capacity}, #{status}, #{createTime}, #{updateTime})")
    void insert(Bus bus);

    @Select("select * from bus where id = #{id}")
    Bus selectById(Long id);

    void deleteByIds(List<Long> ids);

    @Select("select * from bus where id = #{id}")
    BusVO getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Bus bus);
}
